package com.lh.Mybatis.service;

import com.lh.Mybatis.model.Dept;
import com.lh.Mybatis.util.SessionFactory;
import org.apache.ibatis.session.SqlSession;

import java.io.IOException;
import java.util.List;

/**
 * 作者：idea
 * 日期：2018/7/5
 * 描述：
 */
public class DeptService {

    public static String findAllMethod(){
        return "com.lh.Mybatis.dao.IDeptDao.findAll";
    }

    public List<Dept> findAll() throws IOException {
        SqlSession sqlSession= SessionFactory.getSqlSession();
        try {
            return sqlSession.selectList(findAllMethod());
        }finally {
            sqlSession.close();
        }
    }

    public static void main(String[] args) throws IOException {
        DeptService ds=new DeptService();
        System.out.println(ds.findAll().size());
    }

}
